<?php
	class LoginController extends CController{
		private $result = array("actionStatus"=>0,"actionMessage"=>"","model"=>array(),"actionError"=>array());
		public $mainMenu = "Guru Dan Pelajaran";
		public $subMenu = "";
		public $title = "";
		
		public function actionIndex(){
			LoginUser::logout();
			$this->layout ="//layouts/ly_login";
			$this->render('login_form');
		}
		
		public function actionValidate(){
			//print_r($_REQUEST);
			$username = Yii::app()->request->getParam("username","");
			$password = Yii::app()->request->getParam("password","");
			$user = MUser::model()->find("user_name =:username and password =:password and is_active = true and module='keuangan'",array(":username"=>$username ,":password" =>$password));
			if ($user == null){
				$this->redirect(array('keuangan/login','error'=>Yii::t("label", "Username atau password salah")));
			}else{
				Yii::app()->session['LOGIN_USER'] = $user;
				Yii::app()->session['LOGIN_MODULE'] = 'KEUANGAN';
				Yii::app()->session['LOGIN_EXPIRE'] = time() + Yii::app()->params['loginTimeout'];
				
				$this->redirect(array('keuangan/menu'));		
			}
		}				
	}
?>